//
//  FoodCourseCell.m
//  zhangchu
//
//  Created by aoyolo on 15/10/30.
//  Copyright © 2015年 李祖铜. All rights reserved.
//

#import "FoodCourseCell.h"
#import "FoodModel.h"
#import "UIImageView+WebCache.h"

@implementation FoodCourseCell

- (void)awakeFromNib {
    // Initialization code
}

//加载模型显示在控件上
-(void)setFoodCourse:(FoodModel *)foodmodel
{
    self.labeltitle.text = foodmodel.title;
    self.labeltime.text = [self time:foodmodel.create_time];
    self.labeldescrip.text = foodmodel.descript;
    self.labeltitle2.text = [NSString stringWithFormat:@"推荐: %@",foodmodel.title2];
    self.labeldescrip2.text = foodmodel.descript2;
    self.labelplay.text = [NSString stringWithFormat:@"播放 %@ 次",foodmodel.play];
    self.labelVideolength.text = [self playLength:foodmodel.video_length];
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:foodmodel.image] placeholderImage:[UIImage imageNamed:@"image"]];
    
}
//计算视频的长度并把秒转换为时分秒 00：00：00
-(NSString *)playLength:(NSString *)length
{
    NSInteger videoTime = [length integerValue];
    NSInteger h,m,s;
    h = videoTime/3600;
    m = (videoTime/60)%60;
    s = videoTime % 60;
    
    return [NSString stringWithFormat:@"%.2ld:%.2ld:%.2ld", (long)h, (long)m, (long)s];
}

//把秒转换为日期 / / /
-(NSString *)time:(NSNumber *)timeInterVals
{
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:[timeInterVals integerValue]];
    
    NSDateFormatter *format = [[NSDateFormatter alloc]init];
    NSLocale *local = [NSLocale localeWithLocaleIdentifier:@"zh_CN"];
    format.locale = local;
    
    format.dateFormat = @"yyyy/MM/dd EEEE";
    
    return [format stringFromDate:date];
}

                    
                    
                    
                    
                    
                    
                    
                    
                    
@end
